<html>
<head><meta charset="utf-8"><title>SIMD floats · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html">SIMD floats</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="211297055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/211297055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#211297055">(Sep 25 2020 at 18:38)</a>:</h4>
<p>So in aarch64 and x86_64, we have real deal IEEE754 floating point numbers afaik. However, in other machines, we don't have such a guarantee, and LLVM implifies a highly... peculiar semantics regarding NaNs, and even on those two platforms there are some oddities that can crop up. I believe investigating and recommending an answer on how to deal with this will be a key concern for this group, because floating point and SIMD go together very closely, and that like const-eval we may wish to give floating point its own feature flag (done for const fns in <a href="https://github.com/rust-lang/rust/issues/77122">#77122</a>).</p>



<a name="211328339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/211328339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#211328339">(Sep 25 2020 at 23:17)</a>:</h4>
<p>Is this behavior any different than scalar floats?</p>



<a name="211339117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/211339117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#211339117">(Sep 26 2020 at 03:13)</a>:</h4>
<p>Platforms with double-extended precision scalar floats generally do not have double-extended precision SIMD floats, so yes. And Rust already uses double-extended precision scalar floats in some places (this may or may not be intentional).</p>
<p>And platforms without double-extended precision scalar floats may, in their SIMD float, implicitly flush subnormal floats to zero, while having IEEE754 compliant scalar float registers.</p>



<a name="211339188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/211339188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#211339188">(Sep 26 2020 at 03:15)</a>:</h4>
<p>aarch64 is basically the only one I am aware of that does not have an <em>opportunity</em> to experience "quirks" like these, though x86_64 usually doesn't because LLVM tells it to behave and it mostly does.</p>



<a name="211339243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/211339243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#211339243">(Sep 26 2020 at 03:16)</a>:</h4>
<div class="message_inline_image"><a href="https://pbs.twimg.com/media/D36Y3DzXsAMHbuu.jpg"><img src="https://pbs.twimg.com/media/D36Y3DzXsAMHbuu.jpg"></a></div>



<a name="212419777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/212419777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#212419777">(Oct 06 2020 at 12:29)</a>:</h4>
<p>I haven't ever seen LLVM do anything weird to floats that are part of vectors, and I think I'd have noticed since <code>__m128</code> is basically treated as a bag of bits by intels APIs — this includes NaNs, as all the mask values are NaNs.</p>
<blockquote>
<p>LLVM implifies a highly... peculiar semantics regarding NaNs, </p>
</blockquote>
<p>i also think it turned out that this was a llvm bug, which has been fixed: <a href="https://bugs.llvm.org/show_bug.cgi?id=43907">https://bugs.llvm.org/show_bug.cgi?id=43907</a>. I suspect they'd fix other similar issues if they were pointed out in sufficient detail.</p>



<a name="212423709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/212423709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#212423709">(Oct 06 2020 at 13:02)</a>:</h4>
<blockquote>
<p>However, in other machines, we don't have such a guarantee</p>
</blockquote>
<p>So, assuming you mean for vectors (and aren't talking about e.g. x87) — which platforms are you referring to here? I'm not exactly surprised by this, but I think it would be worth knowing about. Most common targets do — intel (sse/avx), arm (neon), ppc (altivec), mips (msa), wasm (i think) ... — these all at least <em>claim</em> to be IEEE754 compliant for f32xN vectors.</p>
<p>I imagine something like hexagon (or other DSPs, future potential GPU targets, etc) might not? That said, implementing software fp to get ieee754-compliance on these targets for the sake of ieee754 compat would be a large amount of work for a result that i firmly believe absolutely noone wants.</p>
<p>I think the bigger issue for those targets is that i don't know if we can really implement e.g. transcendental functions if we can't assume at least <em>some level</em> of ieee754 compatibility — doing these typically requires some bit-juggling.</p>



<a name="212485817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/212485817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#212485817">(Oct 06 2020 at 21:07)</a>:</h4>
<p>So, re: ARM, aarch64 does not have this problem. <strong>But</strong> ARMv7 Neon is known to flush subnormal floats on vector registers. And yes, subnormal float handling is part of ieee754.</p>
<p>I have observed oddities regarding MIPS float handling, especially with respect to NaNs, but I haven't pinpointed all the issues there yet.<br>
I am not sure about the state of PowerPC float handling, but I have adopted a slightly more conservative "the jury is out!" stance. <code>ppc64le</code> seems well-behaved, but I am less confident about other PowerPC targets.<br>
WASM is... IEEE754<strong>ish</strong>, and the NaN thing is basically where the jury is out, if memory serves. As in, yes, WASM handles NaNs in a particular fashion that may not be IEEE754 compliant.<br>
Like, to be clear, the problem is more "everyone is 98% compliant, and that last 2% of noncompliance is stuff we need to be on our toes for."</p>



<a name="212486361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/212486361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#212486361">(Oct 06 2020 at 21:11)</a>:</h4>
<p>I think we should be able to do bitwhacking on most platforms, but I think we need to basically write tests for our bitwhacking assumptions, especially since this will also overlap with endianness concerns.</p>



<a name="212489988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/212489988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#212489988">(Oct 06 2020 at 21:44)</a>:</h4>
<p>Yeah, bit hacking floats is exactly what you <em>can't</em> quite do in all cases on i586, for example.</p>



<a name="212491228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/212491228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#212491228">(Oct 06 2020 at 21:57)</a>:</h4>
<blockquote>
<p>But ARMv7 Neon is known to flush subnormal floats on vector registers. And yes, subnormal float handling is part of ieee754.</p>
</blockquote>
<p>ah, yeah, so I had forgotten that ARM has subnormal flushing on by default, this isn't a big problem though (as i talk about later).</p>
<blockquote>
<p>I have observed oddities regarding MIPS float handling, especially with respect to NaNs, but I haven't pinpointed all the issues there yet.</p>
</blockquote>
<p>Ah right, MIPS flips the bitwise representation of sNaN and qNaN. E.g. the most significant bit in the mantissa indicates a qNaN everywhere else, but an sNaN for MIPS (I think sparc does this too? someone who is basically irrelevant now also does).</p>
<p>I think other than that they're fine? But it does need to be handled.</p>
<blockquote>
<p>I am not sure about the state of PowerPC float handling, but I have adopted a slightly more conservative "the jury is out!" stance. ppc64le seems well-behaved, but I am less confident about other PowerPC targets.</p>
</blockquote>
<p>I used to do a lot of stuff on PPC and remember its floats being well behaved with the notable exception that their <code>long double</code> is absolutely buckwild (it's just two f64s that you must together to get the real value. the number of distinct representations of, say, 0.0, that this gives you is left as an exercise <span aria-label="stuck out tongue" class="emoji emoji-1f61b" role="img" title="stuck out tongue">:stuck_out_tongue:</span>).</p>
<p>Anyway, <code>long double</code> doesn't matter to us, but I will never pass up a chance to complain about it (and IIRC it doesn't even have hardware support so who knows why it's the way it is)</p>
<blockquote>
<p>WASM is... IEEE754ish, and the NaN thing is basically where the jury is out, if memory serves. As in, yes, WASM handles NaNs in a particular fashion that may not be IEEE754 compliant.</p>
</blockquote>
<p>Yeah, so IEEE754 has the notion of non-canonical encodings of a float. For binary32 and binary64, to be strictly compliant, all representations are supposed to be canonical. Historically, the cases of non-canonical floats that I know of were</p>
<ol>
<li>decimal floats but nobody uses these. (not important)</li>
<li>x87's f80 weird pseudo-subnormals. (not important)</li>
<li>platforms that have subnormal flushing to zero enabled (if you the subnormals as non-canonical representations of zero it works perfectly), which is relevant because of ARM.</li>
</ol>
<p>It looks like (I haven't actually compared it exactly, just skimmed) that wasm just treats all nans as non-canonical versions of some canonical nan, and canonicalizes at the exact same times that ieee754 says to canonicalize.</p>
<p>These all seem pretty fine and easy to handle.</p>
<blockquote>
<p>but I think we need to basically write tests for our bitwhacking assumptions, especially since this will also overlap with endianness concerns.</p>
</blockquote>
<p>Yes, this all definitely falls into the camp of "untested code is probably broken".</p>



<a name="212494232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/212494232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#212494232">(Oct 06 2020 at 22:31)</a>:</h4>
<p>Oh and yes... there is something that I only understood recently.<br>
ARMv7 and ARMv8 32-bit ISAs are not completely compatible, and I don't think it's juuust a superset? ARMv8 docs I've seen mention "removing cruft" <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span>  Likewise, I am not sure how much Neon is just a superset on ARMv8, I think it's more like the SSE -&gt; SSE2 difference, where some things have different semantics, which is quite obviously the case for Neon since floats have different handling. I am hoping that it's not "ARMv8 Neon does not support all ARMv7 Neon instructions" but uh...</p>



<a name="212678470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/212678470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonathan Bradbury <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#212678470">(Oct 08 2020 at 12:03)</a>:</h4>
<p>On s390x the binary floating point ISA is fully IEEE754 compliant.  Full support of subnormals, and support for binary32, binary64, and binary128 in 128b registers.  The data format in registers is the IEEE binary interchange format so you can do bit tweaking operations on floating point data.</p>



<a name="212731646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/212731646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#212731646">(Oct 08 2020 at 18:32)</a>:</h4>
<p>Ooh, Thom found this:<br>
<span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/Floating-point.20operations.20are.20non-deterministic/near/212675532">said</a>:</p>
<blockquote>
<p>I came across <a href="https://github.com/WebAssembly/design/blob/master/Rationale.md#nan-bit-pattern-nondeterminism">https://github.com/WebAssembly/design/blob/master/Rationale.md#nan-bit-pattern-nondeterminism</a> (and Also see <a href="https://github.com/WebAssembly/design/blob/master/Nondeterminism.md">https://github.com/WebAssembly/design/blob/master/Nondeterminism.md</a>) which is interesting.</p>
<blockquote>
<p>IEEE 754-2008 6.2 says that instructions returning a NaN should return one of their input NaNs. In WebAssembly, implementations may do this, however they are not required to. Since IEEE 754-2008 states this as a "should" (as opposed to a "shall"), it isn't a requirement for IEEE 754-2008 conformance.</p>
</blockquote>
<p>This answers a lot of questions for <a href="https://github.com/rust-lang/rust/issues/73328">https://github.com/rust-lang/rust/issues/73328</a></p>
<p>Specifcally the way it wors is: Certain instructions are not guaranteed to preserve the payload bitpattern (in practice you can't rely on this portably so it seems fine that not to guarantee anything). Specifically:</p>
<ul>
<li>
<p>the instructions fsqrt, fceil, ffloor, ftrunc, fnearest, fadd, fsub, fmul, fdiv, fmin, fmax, promote (<code>f32 as f64</code>) and demote (<code>f64 as f32</code>): : do not preserve the payload or sign bits for non-canonical nans, and do not preserve the sign bit for canonical nans (where "do not preserve means "set to a nondeterministic value").</p>
</li>
<li>
<p>the instructions fneg, fabs, and fcopysign (e.g. "sign bit operations" according to ieee754) fully preserve nan payload, and only modify the sign bit if expected for the operation, and introduce no nondeterminsim. (this is actually a hard requirement of IEEE754 so it's not surprising if they're going with the "technically compliant" argument lol)</p>
</li>
</ul>
<p>All other operations, such as copying values around, loading/storing them to memory, roundtripping arbitrary bitpatterns (including the patterns of noncanonical nans) through float values, using them as args, returning them from functions... these should all preserve sign and payload of nans.</p>
<p>As I mentioned before you can't portably rely on what happens to these NaN payloads if you do math on them, so I don't think what's there is a big deal if this is followed. My big concern was mostly that that last set of things wouldn't work.</p>
</blockquote>
<p>This helps a lot... kinda. :V</p>



<a name="212733928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/212733928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#212733928">(Oct 08 2020 at 18:51)</a>:</h4>
<p>yeah, i was following up on my statement that</p>
<blockquote>
<p>It looks like (I haven't actually compared it exactly, just skimmed) that wasm just treats all nans as non-canonical versions of some canonical nan, and canonicalizes at the exact same times that ieee754 says to canonicalize.</p>
</blockquote>
<p>So, this ended up being not true. I had been thrown off a bit by wasm's use of the term "canonical" for certain NaNs, but it's not referring to the same thing.</p>
<p>What wasm does is pretty similar (it <em>does</em> happen at the same times when ieee754 would canonicalize), but instead of collapsing to a single value, it instead states that certain bits in the float have become non-determinstic.</p>
<p>(note: I'm not 100% certain but I suspect they're wrong that an implementation that can produce non-deterministic results is still fully compliant, but I have to study the ieee754 spec more closely to be sure...)</p>
<p>Ultimately I think it requires a bit more though on what this means for our public API/guarantees, but in practice I'm not that worried, mostly because these things do all happen to at the same time canonicalization happens, which we already knew we'd have to worry about a little.</p>



<a name="212734468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/212734468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#212734468">(Oct 08 2020 at 18:56)</a>:</h4>
<p>Anyway, it's neither here nor there, but once I have done more reading and such, I think I might end up reaching out to them for some clarification on this, because (as ralf pointed out in one of the threads somewhere), this actually inhibits optimizations that allowed when targetting wasm (since many of them will become value-changing), which feels very much unintentional given their design rationale.</p>



<a name="213053772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/213053772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#213053772">(Oct 12 2020 at 15:36)</a>:</h4>
<p><a href="https://github.com/Lokathor/wide/pull/67#issuecomment-706761224">https://github.com/Lokathor/wide/pull/67#issuecomment-706761224</a> Not SIMD-specific but a float issue and I am LOVIN' IT.</p>



<a name="213067311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/213067311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#213067311">(Oct 12 2020 at 17:45)</a>:</h4>
<p><span class="user-mention" data-user-id="209168">@Thom Chiovoloni</span> Also, thank you for being so informative re: floats! No, really.<br>
You seemed slightly concerned about telling me something I might already know, so I just want to say that while yes, I will harrumph slightly if you tell me something I <em>completely</em> already know at some point, but it's completely fine to cover a subject completely as part of explaining something new (to me) and retread a bit of material in doing so. Especially if I have gotten it visibly inarguably incorrect! You aren't required to know the exact state of knowledge in my brain.</p>



<a name="213067597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/213067597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#213067597">(Oct 12 2020 at 17:48)</a>:</h4>
<p>Ooh apparently that was guilty of rounding then truncating.</p>



<a name="213068366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/213068366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#213068366">(Oct 12 2020 at 17:56)</a>:</h4>
<p>yeah, my bad on the code review there</p>



<a name="213068380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/213068380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#213068380">(Oct 12 2020 at 17:56)</a>:</h4>
<p>It's a complex enough topic that "inarguably incorrect" is rarely the status — It's not at all impossible that I'm wrong (I was before about NaN on wasm), and I want to make sure that it's not a situation where you were aware of the thing I'm saying, and deliberately demonstrating a counterexample, or whatever. But also people have different sensitives around this, and I didn't want you to feel like I was mansplaining — especially given the above, where it's possible you were already aware of what I'm saying. But... in general it's also just how I am. Yay social anxiety.</p>



<a name="213068646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/213068646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#213068646">(Oct 12 2020 at 17:59)</a>:</h4>
<p>I know hardly anything about ieee 754 beyond the bare minimum so I give you permission to explain even extremely simple things to me <span aria-label="grinning face with smiling eyes" class="emoji emoji-1f601" role="img" title="grinning face with smiling eyes">:grinning_face_with_smiling_eyes:</span></p>



<a name="213069971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/213069971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#213069971">(Oct 12 2020 at 18:14)</a>:</h4>
<p>That's also why I'm Explicitly Granting Permission, because I know what social anxiety is like! I also have in fact been someone who has been sensitive about this in the past, so I know what that's like too? But I am much, much more chill about most things now, and more interested in learning than anything. I am not going to do something silly like promise I will never go "huff!" at something you say, but if I do I will attempt to directly resolve the problem... not, like, swear a grudge on you forever or something.</p>
<p>The concern where I was obviously a bit confused was about reading ARM asm, which technically "isn't" about floating point at all.</p>



<a name="213959921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/213959921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#213959921">(Oct 20 2020 at 18:22)</a>:</h4>
<p>Have been reading The Standard.</p>



<a name="213959976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/213959976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#213959976">(Oct 20 2020 at 18:22)</a>:</h4>
<p>IEEE754-2019 in particular.</p>



<a name="213966554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/213966554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#213966554">(Oct 20 2020 at 19:13)</a>:</h4>
<p>it's a good standard</p>



<a name="213967059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/213967059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#213967059">(Oct 20 2020 at 19:17)</a>:</h4>
<p>I believe Rust will need some updates to its float implementation period, but I have to start drafting the relevant tests to be sure.</p>



<a name="214255900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/214255900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#214255900">(Oct 22 2020 at 22:30)</a>:</h4>
<p>Yeah, I think we violate a few "shall" terms.</p>



<a name="214255928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/214255928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#214255928">(Oct 22 2020 at 22:30)</a>:</h4>
<p>Specifically at one of the most underloved intersections of the compiler: fmt and float.</p>



<a name="214461954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/214461954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#214461954">(Oct 25 2020 at 01:59)</a>:</h4>
<p>confirmed. drafting tests as I go.</p>



<a name="215219920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/215219920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#215219920">(Nov 01 2020 at 01:07)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/78618">https://github.com/rust-lang/rust/pull/78618</a><br>
<a href="/user_uploads/4715/QHzPQ52Kqypgg3LzMCWpTE0f/Elmo-Flames-Meme.png">Elmo-Flames-Meme.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/QHzPQ52Kqypgg3LzMCWpTE0f/Elmo-Flames-Meme.png" title="Elmo-Flames-Meme.png"><img src="/user_uploads/4715/QHzPQ52Kqypgg3LzMCWpTE0f/Elmo-Flames-Meme.png"></a></div>



<a name="215230198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/215230198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#215230198">(Nov 01 2020 at 06:29)</a>:</h4>
<p>:3c</p>



<a name="215234166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/215234166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#215234166">(Nov 01 2020 at 08:45)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span> on <code>-0</code>. It looks like that’s how .NET formats them too</p>



<a name="215248702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/215248702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#215248702">(Nov 01 2020 at 15:24)</a>:</h4>
<p>what's the connection to .NET?</p>



<a name="215256931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/215256931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#215256931">(Nov 01 2020 at 18:56)</a>:</h4>
<p>Actually, .NET Framework used 0.0, and .NET Core uses -0.0!</p>



<a name="215256943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/215256943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#215256943">(Nov 01 2020 at 18:56)</a>:</h4>
<p>I presume there is no connection being made other than observing how other languages do it. So it's worth noting that C# considered this a bug and fixed it. <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="215261608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/215261608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#215261608">(Nov 01 2020 at 20:46)</a>:</h4>
<p>in Julia I get </p>
<div class="codehilite" data-code-language="Julia"><pre><span></span><code><span class="n">Vec</span><span class="p">{</span><span class="mi">2</span><span class="p">,</span><span class="kt">Float64</span><span class="p">}((</span><span class="o">-</span><span class="mi">0</span><span class="p">,</span><span class="o">-</span><span class="mf">0.0</span><span class="p">))</span>
<span class="o">&lt;</span><span class="mi">2</span> <span class="n">x</span> <span class="kt">Float64</span><span class="o">&gt;</span><span class="p">[</span><span class="mf">0.0</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.0</span><span class="p">]</span>
</code></pre></div>
<div class="codehilite" data-code-language="Julia"><pre><span></span><code><span class="n">Vec</span><span class="p">{</span><span class="mi">2</span><span class="p">,</span><span class="kt">Int64</span><span class="p">}((</span><span class="o">-</span><span class="mi">0</span><span class="p">,</span><span class="o">-</span><span class="mf">0.0</span><span class="p">))</span>
<span class="o">&lt;</span><span class="mi">2</span> <span class="n">x</span> <span class="kt">Int64</span><span class="o">&gt;</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span>
</code></pre></div>



<a name="215261649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/215261649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#215261649">(Nov 01 2020 at 20:48)</a>:</h4>
<p>I don't know Julia, but I assume -0 is an integer literal, which is why it doesn't keep the sign?</p>



<a name="215261700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/215261700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#215261700">(Nov 01 2020 at 20:49)</a>:</h4>
<p>that's correct</p>



<a name="215261761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/215261761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#215261761">(Nov 01 2020 at 20:50)</a>:</h4>
<p>there's some documentation here: <a href="https://juliapackages.com/p/simd">https://juliapackages.com/p/simd</a></p>



<a name="215262094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/215262094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#215262094">(Nov 01 2020 at 21:00)</a>:</h4>
<p>Sorry, yep that was it <span aria-label="big smile" class="emoji emoji-1f604" role="img" title="big smile">:big_smile:</span> I also wasn’t aware .NET Framework printed <code>0.0</code>!</p>



<a name="215263792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/SIMD%20floats/near/215263792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/SIMD.20floats.html#215263792">(Nov 01 2020 at 21:45)</a>:</h4>
<p>Yeah, it is something that surfaced while auditing a <em>lot</em> of different languages for how they print floats.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>